<html>
	<head>
		<title>责任链模式</title>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<script>
			function Handler(s) {
				this.successor = s || null;
			}


			Handler.prototype = {
				handle : function() {
					if (this.successor) {
						this.successor.handle()
					}
				}
			};

			var app = new Handler({
				handle : function() {
					console.log('app handle');
				}
			});

			var dialog = new Handler(app);
			dialog.handle = function() {
				console.log('dialog before ...')
				// 这里做具体的处理操作
				console.log('dialog after ...')
			};

			var button = new Handler(dialog);
			button.handle = function() {
				console.log('button before ...')
				// 这里做具体的处理操作
				//console.log(this);
				Handler.prototype.handle.call(this);
				//处理完成后继续button after
				console.log('button after ...')
			};
			button.handle();
		</script>
	</head>
	<body></body>
</html>